<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<input v-model="itemName"/>
			<button v-on:click="add">添加</button>
			<table>
				<tr v-for="item in itemList">
					<td>{{item}}</td>
				</tr>
			</table>
		</div>
	</body>
</html>
<script src="vue.js"></script>
<script>
	let config={
		"el":"#app",
		"data":{
			"itemName":"请输入商品名称",
			"itemList":["item1","item2"]
		},
		"methods":{
			"add":function(){
				//window.alert(this.itemName)
				//把输入的商品放到集合里了
				this.itemList.push(this.itemName)
			}
		}
	}
	new Vue(config)
</script>